import axios from 'axios'

export const TenderPurchasePlanService = class TenderPurchasePlanService {
    static tenderPurchasePlanService = null
    requestUrl = 'http://localhost/tenderPurchasePlans'

    static getInstance() {
        if (this.tenderPurchasePlanService == null) {
            this.tenderPurchasePlanService = new TenderPurchasePlanService()
        }
        return this.tenderPurchasePlanService
    }

    /**
     * 查询投标项目信息的方法
     * @param params
     * @returns {Promise<AxiosResponse<T>>}
     */
    getPageList(params) {
        return axios.get(`${this.requestUrl}/page`, {
            params
        })
    }

    /**
     * 获取最大编号的方法
     */
    getMaxCode() {
        return axios.get(`${this.requestUrl}/code`)
    }

    /**
     * 保存的方法
     * @param tenderPurchasePlan
     * @param tenderPurchaseDetails
     */
    save(tenderPurchasePlan, tenderPurchaseDetails) {
        const params = {
            tenderPurchasePlan: tenderPurchasePlan,
            tenderPurchaseDetails: tenderPurchaseDetails
        }
       return axios.post(this.requestUrl, params)
    }

    /**
     * 根据id查询
     * @param id
     */
    getById(id) {
        return axios.get(`${this.requestUrl}/${id}`)
    }

    /**
     * 获取审批通过的全部
     */
    list() {
        return axios.get(this.requestUrl)
    }
}
